package model;

/**
 *
 * @author Dustin
 */
public class Card implements Comparable {
    /**
     * The amount of suites
     */
    public final static int SUITES = 4;
    /**
     * The amount of ranks ranging from 1 to 13
     */
    public final static int RANKS = 13;

    public final static int SPADES = 0;
    public final static int HEARTS = 1;
    public final static int DIAMONDS = 2;
    public final static int CLUBS = 3;

    private int suite;
    private int rank;

    /**
     * Constructs a new Card with given suite and rank
     * @param aSuite
     * @param aRank
     */
    public Card(int aSuite, int aRank) {
        suite = aSuite;
        rank = aRank;
    }

    public int getSuite() {
        return suite;
    }

    public int getRank() {
        return rank;
    }

    public String toString() {
        String card = "";
        card += rank + " of ";
        switch(suite) {
            case SPADES:
                card += "Spades";
                break;
            case HEARTS:
                card += "Hearts";
                break;
            case DIAMONDS:
                card += "Diamonds";
                break;
            case CLUBS:
                card += "Clubs";
                break;
        }
        return card;
    }

    public void setSuite(int aSuite) {
        suite = aSuite;
    }

    public void setRank(int aRank) {
        rank = aRank;
    }

    /**
     * Command to compare the given Card with this Card
     * @param o
     * @return
     */
    public int compareTo(Object o) {
        Card c = (Card) o;
        int value = 0;

        if(suite < c.suite) {
            value = -1;
        } else if(suite > c.suite) {
            value = 1;
        }
        
        if(value == 0) {
            if(rank < c.rank) {
                value = -1;
            } else if(rank > c.rank) {
                value = 1;
            }
        }
        
        return value;
    }
}
